export class baseClass{
    constructor(){

    }
    reload(data: any) {
        for (let key in data) {
            if (key.startsWith('_')) continue;
            if (this.hasOwnProperty(key) && this[key as keyof this] instanceof Map) {
                (this[key as keyof this] as Map<any, any>).clear();
                (this[key as keyof this] as Map<any, any>).set(data[key][0], data[key][1]);
            } else if (this.hasOwnProperty(key)) {
                (this as any)[key] = data[key];
            }
        }
    }

    resave() {
        const data: any = {};
        for (let key in this) {
            if (key.startsWith('_')) continue;
            if (this[key] instanceof Map) {
                data[key] = Array.from((this[key] as Map<any, any>).entries());
            } else {
                data[key] = this[key];
            }
        }
        return data;
    }
}